<template>
  <el-dialog :model-value="true" title="服务商佣金记录" width="60%" @close="emits('close')">
    <div class="flex flex-col">
      <el-table v-loading="loading" :data="list">
        <el-table-column label="佣金记录单号" prop="id" align="center" />
        <el-table-column label="标题" prop="title" align="center" />
        <!-- orderId -->
        <el-table-column label="订单编号" prop="orderId" align="center" />
        <el-table-column label="佣金" prop="realMoney" align="center" />
        <el-table-column label="创建时间" prop="createTime" align="center">
          <template #default="scope">
            <div>{{ formatDate(scope.row.createTime) }}</div>
          </template>
        </el-table-column>
      </el-table>
      <Pagination
        v-model:limit="queryParams.pageSize"
        v-model:page="queryParams.pageNo"
        :total="total"
        @pagination="getRecordList"
      />
    </div>

    <template #footer>
      <div class="flex justify-end">
        <el-button @click="emits('close')">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import ServiceApi from '@/api/application/service'
import { formatDate } from '@/utils/formatTime'

const props = defineProps({
  id: {
    type: Number,
    required: true
  }
})
const emits = defineEmits(['close'])
const queryParams = ref({
  pageNo: 1,
  pageSize: 10,
  servicePartnerId: props.id
})
const total = ref(0)
const loading = ref(false)
const list = ref([])
const getRecordList = async () => {
  const res = await ServiceApi.getServiceRecordPage(queryParams.value)
  list.value = res.list
  total.value = res.total
}
onMounted(() => {
  getRecordList()
})
</script>
